package com.xyw.code.study20200813.test;

import java.util.*;

import static java.util.Collections.synchronizedCollection;

/**
 * Created with IntelliJ IDEA.
 * User: xuyiwei
 * Date: 2020/8/28
 * Time: 上午10:43
 * Email: 1328312923@qq.com
 * Description: No Description
 **/
public class ListTest2 {
    public static void main(String[] args) {
        ArrayList<Integer> arrayList = new ArrayList<Integer>();
        arrayList.add(1);
        arrayList.add(2);
        arrayList.add(3);
        arrayList.add(4);
        arrayList.add(5);
        arrayList.add(6);
        arrayList.add(7);
        arrayList.add(8);
        arrayList = (ArrayList<Integer>) ListTest2.reverse(arrayList);
        System.out.println( arrayList );
        Collections.sort(arrayList);
    }

    public static <T> List reverse(List<T> list){
        List<T> collections = new ArrayList<>();
        for(int i=list.size()-1;i>=0;i--){
            collections.add(list.get(i));
        }
        list = collections;
        return list;
    }
}
